<?php

namespace App\Model;


use Illuminate\Support\Facades\DB;

class PropMall extends BaseModel
{
    protected $connection = 'api';
    protected $table = 'prop_mall';


    public function getList($input)
    {
        $page = $input['page'] ?? 1;
        $limit = $input['limit'] ?? 10;
        return DB::connection($this->connection)->table($this->table)->orderBy('sort','desc')->paginate($limit, '*', 'page', $page);
    }

    /**
     * 创建或更新
     * prop_id 存在则更新，不存在则新增
     * @param $data
     * @return mixed
     */
    public function createOrUpdateData($data)
    {
        return curl_request(getKkaudioApiUrl() . '/inner/prop_config/mall/upsert', $data, 'json', 'POST');
    }


    //删除
    public function delGoods($id)
    {
        return curl_request(getKkaudioApiUrl() . '/inner/prop_config/mall/del', ['goods_id' => $id], 'urlencoded', 'GET');
    }
}
